package com.zzxx.mapper;

import com.zzxx.entity.Orders;
import org.apache.ibatis.annotations.One;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.type.JdbcType;

import java.util.List;

public interface OrdersMapperEx {
    @Results({
            @Result(column="id", property="id", jdbcType= JdbcType.VARCHAR, id=true),
            @Result(column="bookerId", property="bookerid", jdbcType=JdbcType.VARCHAR),
            @Result(column="bookTime", property="booktime", jdbcType=JdbcType.DATE),
            @Result(column="status", property="status", jdbcType=JdbcType.INTEGER),
            @Result(column="checkType", property="checktype", jdbcType=JdbcType.INTEGER),
            @Result(column="introduce", property="introduce", jdbcType=JdbcType.VARCHAR),
            @Result(column="objType", property="objtype", jdbcType=JdbcType.INTEGER),
            @Result(column="ticketId", property="ticketid", jdbcType=JdbcType.VARCHAR),
            @Result(column="couponId", property="couponid", jdbcType=JdbcType.VARCHAR),
            @Result(column="createTime", property="createtime", jdbcType=JdbcType.TIMESTAMP),
            @Result(column="managerId", property="managerid", jdbcType=JdbcType.VARCHAR),
            @Result(column="objId", property="objid", jdbcType=JdbcType.VARCHAR),
            @Result(column = "ticketId",property = "ticket",
                    one = @One(select = "com.zzxx.mapper.TicketMapper.selectByPrimaryKey"))
    })
    @Select("select * from orders where bookerId=#{uid} and objType=0")
    List<Orders> findTicketByUid(String uid);

    @Results({
            @Result(column="id", property="id", jdbcType=JdbcType.VARCHAR, id=true),
            @Result(column="bookerId", property="bookerid", jdbcType=JdbcType.VARCHAR),
            @Result(column="bookTime", property="booktime", jdbcType=JdbcType.DATE),
            @Result(column="status", property="status", jdbcType=JdbcType.INTEGER),
            @Result(column="checkType", property="checktype", jdbcType=JdbcType.INTEGER),
            @Result(column="introduce", property="introduce", jdbcType=JdbcType.VARCHAR),
            @Result(column="objType", property="objtype", jdbcType=JdbcType.INTEGER),
            @Result(column="ticketId", property="ticketid", jdbcType=JdbcType.VARCHAR),
            @Result(column="couponId", property="couponid", jdbcType=JdbcType.VARCHAR),
            @Result(column="createTime", property="createtime", jdbcType=JdbcType.TIMESTAMP),
            @Result(column="managerId", property="managerid", jdbcType=JdbcType.VARCHAR),
            @Result(column="objId", property="objid", jdbcType=JdbcType.VARCHAR),
            @Result(column = "ticketId",property = "ticket",
                    one = @One(select = "com.zzxx.mapper.TicketMapper.findOne"))
    })
    @Select("select * from orders where id=#{id}")
    List<Orders> findGymTicketByOid(String id);

    @Results({
            @Result(column="id", property="id", jdbcType=JdbcType.VARCHAR, id=true),
            @Result(column="bookerId", property="bookerid", jdbcType=JdbcType.VARCHAR),
            @Result(column="bookTime", property="booktime", jdbcType=JdbcType.DATE),
            @Result(column="status", property="status", jdbcType=JdbcType.INTEGER),
            @Result(column="checkType", property="checktype", jdbcType=JdbcType.INTEGER),
            @Result(column="introduce", property="introduce", jdbcType=JdbcType.VARCHAR),
            @Result(column="objType", property="objtype", jdbcType=JdbcType.INTEGER),
            @Result(column="ticketId", property="ticketid", jdbcType=JdbcType.VARCHAR),
            @Result(column="couponId", property="couponid", jdbcType=JdbcType.VARCHAR),
            @Result(column="createTime", property="createtime", jdbcType=JdbcType.TIMESTAMP),
            @Result(column="managerId", property="managerid", jdbcType=JdbcType.VARCHAR),
            @Result(column="objId", property="objid", jdbcType=JdbcType.VARCHAR),
            @Result(column = "objId",property = "activity",
                    one = @One(select = "com.zzxx.mapper.ActivityMapper.selectByPrimaryKey"))
    })
    @Select("select * from orders where bookerId=#{uid} and objType=1")
    List<Orders> findActivityByUid(String id);
}
